Hello ABCTG and Matt,
As I’ve done on futures.io I’m posting here the code without some parts.
I removed the code entry logic and some other parts BUT the case entry that you can see here is the case of this morning and after the code you can see the trade that SHOULD HAVE BEEN DONE:
// .................Variable definitions
// Calculate BIAS for the start of the day..
if time > 0810 and time < 0911 then begin
if OpenD(0) > oYesterdaysTPOVAHigh then BIAS = 2;
if OpenD(0) < oYesterdaysTPOVAHigh and OpenD(0) > oYesterdaysTPOVALow then BIAS = 1;
if OpenD(0) < oYesterdaysTPOVALow then BIAS = 0;
//print("-----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"---> day open is ", NumToStr(OpenD(0),2));
end;
if time = Time_CLOSE_SESSION then BIAS = 99; // reset di sicurezza evitiamo di operare e fallare i back test usando bias precedenti
// Fixed Stop loss
setstoploss( Stoploss * bigpointvalue);
//Time frame of the day where entries are allowed
isTheRightTime = ( time >= Time_MorningStart_at and time <= Time_MorningStop_at) or ( time >= Time_AfternoonStart_at and time <= Time_AfternoonStop_at);
// INTRADAY changes of BIAS if allowed
if BIAScanChangeIntraday then begin
// Here I change the daily BIAS only if there were not trade and some conditions are met
end;
if marketposition = 0 and isTheRightTime and (( positionprofit(1) < 0 and EntriesToday(Date) > 0 ) = false)
then begin
EntryMode = 0;
SEprotection = false;
LEprotection = false;
canPrintEntryprice = false;
// SOME OTHER ENTRY CASES REMOVED..............
if BIAS = 0 and // THIS IS YESTERDAY CASE
// some more code conditions
Price >= oYesterdaysTPOVALow and Price - oYesterdaysTPOVALow <= 10
then begin
EntryMode = 8;
sellshort("Bear SE 8") 1 contract next bar at oYesterdaysTPOVALow + 3 limit; //stop oYesterdaysTPOVAHigh - 3 limit;
canPrintEntryprice = true;
end;
end;
if marketposition = -1 then begin
//if openpositionprofit >= gainProtectionTriggerTicks * bigpointvalue then SEprotection = true;
if entryprice - Price >= gainProtectionTriggerTicks then SEprotection = true; // con questo guadagna pi che con openprofit.. misteroZ
switch(EntryMode)
begin
case 8: begin
if canPrintEntryprice then begin
if printDebug then print("n. ",NumToStr(totaltrades + 1,0)," -----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"-------> SHORT SE 8 at ", NumToStr(entryprice,2),NewLine);
canPrintEntryprice = false;
end;
if Price <= oYesterdaysTPOVALow - ( ( oYesterdaysTPOVAHigh - oYesterdaysTPOVALow ) / 2 ) then begin
buytocover("Bear SX8") 1 contract next bar at market;
EntryMode = 0;
if printDebug then print(" yVAL = ", NumToStr( oYesterdaysTPOVALow ,0 ),newline);
if printDebug then print("------Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"------> BEAR SX8 at ", NumToStr(entryprice,2),
" -- TRADE exit around --> ", NumToStr( price, 2), NewLine);
end;
// Alternative exit in case of congestion before an up trend ---> controllando 6 barre non male... pure 4 ... fai test
if H[4] > oYesterdaysTPOVALow and H[3] > oYesterdaysTPOVALow and H[2] > oYesterdaysTPOVALow and H[1] > oYesterdaysTPOVALow and
L[4] < oYesterdaysTPOVALow and L[3] < oYesterdaysTPOVALow and L[2] < oYesterdaysTPOVALow and L[1] < oYesterdaysTPOVALow and
price < oYesterdaysTPOVALow - 5
then begin
buytocover("Bear SX8 protect") 1 contract next bar at market;
EntryMode = 0;
if printDebug then print(" yVAL = ", NumToStr( oYesterdaysTPOVALow ,0 ),newline);
if printDebug then print("-----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"-------> FLAT SX4 at ", NumToStr(entryprice,2),
" -- TRADE exit around --> ", NumToStr( price, 2), NewLine);
end;
end;
if SEprotection then buytocover("SE Protection") 1 contract next bar at entryprice - minTickOfGain stop;
end;
if time >= Time_CLOSE_SESSION and time < 2200 then buytocover("SE CLOSE SESSION") 1 contract next bar at market;
end;
This is the trade that gave me the error in REAL automated trading:
Is it enough the piece of code posted?
As you can see the trade is in the 9:05 bar of 5minutes chart… just 3 tick after that orange level on there should have been a limit short at 12268. I was wondering how much time does an order stay in the market before MC cancel it…
Any idea would be appreciated I really need to have this strategy live after so much work and study …
Thanks again,
David