so, what i am trying to do is, buy a gap lower on daily bar, if Parabolic SAR is negative (going down). i have a stop using average true range also.
it does work half of the time. sometimes, when there is a gap, and SAR is NOT negative on open, but ends up crossing negative, it will buy once it crosses negative. i only want to trade the open; is there a way to do so if IOG is on? i also tried adding 5 min data into chart, and this code...
if (var2 = -1) and marketposition = 0 and date > date[1] and open < low[1] and time of data2 < 850 then....
...but when i did so, no trades occurred.
below is my code.
Code: Select all
[Intrabarordergeneration = True]
inputs: AfStep( 0.02 ), AfLimit( 0.2 ), n_risk(3);
variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 );
Value1 = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 );
{get long}
if (var2 = -1) and marketposition = 0 and date > date[1] and open < low[1] then
{When IntraBarOrderGeneration is turned on, next bar really means next tick}
Buy next bar at open;
{sell if long}
if marketposition = 1 then
Sell next bar at var0 limit;
{stop}
SetStopPosition;
if MarketPosition = 1 then
SetStopLoss((AvgTrueRange(20)) * (n_risk * CurrentContracts));
version information:
Version: MultiCharts64 Version 11.0 Release (Build 16148)
using InteractiveBrokers for data/execution.
image shows the working and non-working instances. my example is using SPY underlying...