I am fairly new to MC so sorry for the rudimentary question. I have a strategy that buys or sells at the open of the next bar when a simple cross occurs. I need to use IOG so that when the signal is tripped, the buy or sell occurs immediately at the open of the next bar. In backtesting this strategy works great. (Historical pic attached...IOG is operational on the left and turned off on the right)
Today I ran the program in a live simulator and a problem occurred....as they often do in real life. The buy order generation worked great when the signal was tripped. However, because the signal was in "IOG mode", it often tripped the sell order and was therefore just canceling out the trade. (Simulated trading pic attached...IOG is operational on the left and turned off on the right)
Is there a way to have the signal for the sell only occur on the next bar and not IOG? Or that only a buy OR a sell can occur in one bar?
Thanks a ton
Code: Select all
[IntrabarOrderGeneration = TRUE]
inputs:
PriceN( Close data2), //Price for Numerator
PriceD( Close data3), //Price for Denominator
LengthF( 1 ), //Average Period
Opening_Momentum (0), //Buy Signal
Closing_Momentum (0); //Sell Signal
variables:
var_Numerator( 0 ), //Averege Numerator Price
var_Denominator( 0 ), //Averege Denominator Price
var_Ratio( 0 ), //Indicator Ratio
var_Ratio_Momentum( 0 ), //Indicator Momentum
tradesize(0);
tradesize = (10000 / close);
tradesize = tradesize +(Netprofit/close);
var_Numerator = Average( PriceN, LengthF ) ;
var_Denominator = Average( PriceD, LengthF ) ;
var_Ratio = var_Numerator / var_Denominator ;
var_Ratio_Momentum = Momentum( var_Ratio, LengthF ) ;
condition1 = var_Ratio_Momentum < Opening_Momentum ;
condition2 = var_Ratio_Momentum > Closing_Momentum ;
if condition1 then
Buy ( "BUY" ) tradesize shares next bar at open ;
if condition2 then
Sell ( "SELL" ) next bar at Open;