Support Board
Date/Time: Sat, 23 Nov 2024 11:43:18 +0000
Post From: Auto Trade System Help
[2024-09-02 12:17:55] |
User357489 - Posts: 72 |
Hi SC Engineering/ all Here is my code for an auto trade system; essentially based on alert conditions, but with a specific stop logic. Alert conditions work when used in Color Bar Based... Buy conditions: =OR( AND(ABS(C - ID2.SG1) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG2) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG3) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG4) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG5) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG6) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG7) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG8) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG9) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG10) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG11) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG12) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG13) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG14) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG15) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG16) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG17) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID2.SG18) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG10) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG11) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG12) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG13) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG14) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG15) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG16) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG17) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0), AND(ABS(C - ID3.SG18) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 > ID5.SG1[-1], ID5.SG12 > ID5.SG12[-1], ID5.SG13 > ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 < 0) ) sell conditions: =OR(
AND(ABS(C - ID2.SG1) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG2) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG3) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG4) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG5) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG6) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG7) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG8) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG9) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG10) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG11) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG12) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG13) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG14) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG15) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG16) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG17) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID2.SG18) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG10) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG11) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG12) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG13) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG14) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG15) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG16) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG17) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0), AND(ABS(C - ID3.SG18) <= (2 * TICKSIZE), ID5.SG1 > 0, ID5.SG1 < ID5.SG1[-1], ID5.SG12 < ID5.SG12[-1], ID5.SG13 < ID5.SG13[-1], ID5.SG24 > 0, ID5.SG10 > 0) ) subsequent attempt at ACSIL : #include "sierrachart.h"
SCDLLName("Ring Bearer") // User inputs SCSFExport scsf_RingBearer(SCStudyInterfaceRef sc) { // Define and set persistent variables SCInputRef EnableTrading = sc.Input[0]; SCInputRef TakeProfitTicks = sc.Input[1]; if (sc.SetDefaults) { // Set the study name and defaults sc.GraphName = "Ring Bearer"; sc.StudyDescription = "Enters trades based on specified conditions with stop loss and take profit."; sc.AutoLoop = 1; // Automatically loop through the bars sc.GraphRegion = 0; // Input defaults EnableTrading.Name = "Enable Trading"; EnableTrading.SetYesNo(0); // Default is OFF TakeProfitTicks.Name = "Take Profit (Ticks)"; TakeProfitTicks.SetInt(10); // Default take profit of 10 ticks return; } // Exit if trading is not enabled if (!EnableTrading.GetYesNo()) return; // Get current and previous bar data float LastClose = sc.Close[sc.Index]; float LastHigh = sc.High[sc.Index]; float LastLow = sc.Low[sc.Index]; float PrevHigh = sc.High[sc.Index - 1]; float PrevLow = sc.Low[sc.Index - 1]; // Determine stop loss based on the lower/high of previous/current bar float StopLoss = min(LastLow, PrevLow); // For long positions float TakeProfit = LastClose + (TakeProfitTicks.GetInt() * sc.TickSize); // Buy entry conditions // Sell entry conditions bool SellCondition = ( (abs(LastClose - sc.Subgraph[1][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[2][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[3][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[4][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[5][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[6][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[7][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[8][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[9][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[10][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[11][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[12][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[13][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[14][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[15][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[16][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[17][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) || (abs(LastClose - sc.Subgraph[18][sc.Index]) <= (2 * sc.TickSize) && sc.Subgraph[5][sc.Index] > 0 && sc.Subgraph[5][sc.Index] < sc.Subgraph[5][sc.Index - 1] && sc.Subgraph[12][sc.Index] < sc.Subgraph[12][sc.Index - 1] && sc.Subgraph[13][sc.Index] < sc.Subgraph[13][sc.Index - 1] && sc.Subgraph[24][sc.Index] > 0 && sc.Subgraph[10][sc.Index] > 0) ); // If buy condition is met, place a buy order if (BuyCondition) { s_SCNewOrder NewOrder; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.OrderQuantity = sc.TradeWindowOrderQuantity; NewOrder.Target1Offset = TakeProfitTicks.GetInt() * sc.TickSize; NewOrder.Stop1Offset = (LastClose - StopLoss); sc.BuyEntry(NewOrder); } // If sell condition is met, place a sell order if (SellCondition) { s_SCNewOrder NewOrder; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.OrderQuantity = sc.TradeWindowOrderQuantity; NewOrder.Target1Offset = TakeProfitTicks.GetInt() * sc.TickSize; NewOrder.Stop1Offset = (StopLoss - LastClose); sc.SellEntry(NewOrder); } } the build compiles successfully, but after observation of an occasion that should have entered a long position, nothing happened. i manually entered and screenshotted what the stop would look like (ie being the lower of either entry bar or entry bar-1 in the case of a long) |