Ninja Trading en el Forex

Miguel

Administrator
Miembro del equipo
Voy a buscar toda la información para operar en futuros del EURUSD en lugar de CFDs
 

Why Forex Futures Are A Preferred Choice Over Spot FX And CFDs​

The forex market, also referred to as the currency market or FX, is the largest capital market in the world, allowing traders to speculate on the exchange rates between major world currencies. Forex futures provide an efficient and effective alternative to trading the spot FX or contract for difference (CFD) markets which introduce a number of pitfalls for traders.
Here we will discuss the various advantages of trading forex futures and currency futures vs spot FX and CFDs, including a well regulated marketplace, transparent pricing and volume and trading on a fair level playing field.
 

Trade Forex Futures To Capitalize On Currency Market Moves​

NinjaTrader offers traders access to all the major foreign currencies traded against the US dollar. Traders can capture potential opportunities in these fast moving markets using a standard futures contract or a Micro sized contact for increased flexibility and reduced capital requirements.
  • Australian Dollar (6A)
  • British Pound (6B)
  • Canadian Dollar (6C)
  • Euro (6E)
  • Japanese Yen (6J)
1718734036329.png
 
El futuro MGE micro E-micro EUR/USD Futures tiene una comisión de 0.09 y un margen de 50 equivale 12,500 dólares

1718737784615.png
 
Código en Interactiva Brokers para enviar ordenes de futuros.

Código:
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.order import Order
import threading
import time

class IBapi(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self, self)
   
    def error(self, reqId, errorCode, errorString):
        print("Error:", reqId, errorCode, errorString)
   
    def nextValidId(self, orderId):
        self.nextOrderId = orderId
        self.start()

    def contractDetails(self, reqId, contractDetails):
        print("ContractDetails:", reqId, contractDetails)

    def historicalData(self, reqId, bar):
        print("HistoricalData:", reqId, bar)

    def start(self):
        contract = Contract()
        contract.symbol = "M6E"
        contract.secType = "FUT"
        contract.exchange = "GLOBEX"
        contract.currency = "USD"
        contract.lastTradeDateOrContractMonth = "202406"

        self.reqMarketDataType(4)
        self.reqHistoricalData(1, contract, "", "1 D", "1 hour", "TRADES", 1, 1, False, [])

        # Example order placement (uncomment to place an order)
        # order = Order()
        # order.action = "BUY"
        # order.totalQuantity = 1
        # order.orderType = "MKT"
        # self.placeOrder(self.nextOrderId, contract, order)

def run_loop():
    app.run()

app = IBapi()
app.connect("127.0.0.1", 7497, clientId=1)

# Start the socket in a thread
api_thread = threading.Thread(target=run_loop, daemon=True)
api_thread.start()

time.sleep(1)  # Allow time for connection to establish

# Request contract details
contract = Contract()
contract.symbol = "M6E"
contract.secType = "FUT"
contract.exchange = "GLOBEX"
contract.currency = "USD"
app.reqContractDetails(0, contract)

time.sleep(5)  # Wait for contract details to be received

app.disconnect()
 
Ejemplo en Ninja Trader:

Código:
// Namespace declaration
using System;
using NinjaTrader.Cbi;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.StrategyAnalyzer;
using NinjaTrader.NinjaScript.StrategyAnalyzer.Optimization;

// Define your strategy class
public class MyM6EStrategy : Strategy
{
    // Initialize method (called once at startup)
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            Description = @"Enter the description for your strategy here.";
            Name = "MyM6EStrategy";
            Calculate = Calculate.OnEachTick;
            EntriesPerDirection = 1;
            EntryHandling = EntryHandling.AllEntries;
            IsOverlay = false;
            ExitOnSessionClose = true;
            IsAccountOrderActionAllowed = true;
            // Configure default parameters for your strategy
            AddEma("EMA", 14);
        }
        else if (State == State.Configure)
        {
            // Add your instruments here
            AddDataSeries("M6E", BarsPeriodType.Minute, 5);
        }
    }

    // OnBarUpdate method (called on each incoming tick)
    protected override void OnBarUpdate()
    {
        // Define your trading logic here
        if (BarsInProgress != 0)
            return;

        // Example: Simple EMA crossover strategy
        if (CrossAbove(EMA(14), Close, 1))
        {
            EnterLong("EMA_CrossAbove");
        }
        else if (CrossBelow(EMA(14), Close, 1))
        {
            EnterShort("EMA_CrossBelow");
        }
    }
}
 
Atrás
Arriba