How can we create our own Candlestickpattern with this code?

Hello. I'm trying to do create own candlestickpattern through optimization, but it doesn't work right at the moment. The code uses only the same value for the whole optimization. What is my mistake?

OwnCandlestickPattern

Here comes the code:

// Define Open, High, Low and Close of the last three days
O1 = Ref(O,-1);
O2 = Ref(O,-2); 
O3 = Ref(O,-3); 
H1 = Ref(H,-1);
H2 = Ref(H,-2);
H3 = Ref(H,-3);  
L1 = Ref(L,-1);
L2 = Ref(L,-2);
L3 = Ref(L,-3); 
C1 = Ref(C,-1);
C2 = Ref(C,-2);
C3 = Ref(C,-3); 

// Define Variables A and B
A = C > 0;
B = O2;

// Define the different Entry Conditions
EntryCondition1 	= A AND O1;
EntryCondition2 	= A AND O2;
EntryCondition3 	= A AND O3;
EntryCondition4		= A AND H1;
EntryCondition5		= A AND H2;
EntryCondition6		= A AND H3;
EntryCondition7		= A AND L1;
EntryCondition8		= A AND L2;
EntryCondition9		= A AND L3;
EntryCondition10	= A AND C1;
EntryCondition11    = A AND C2;
EntryCondition12    = A AND C3;

// Let Entry conditions optimize and redefine Variable A
EntryOpt = Optimize("Optimizer for Entry Rule", 1,1,12,1);
A= VarGet("EntryCondition"+EntryOpt);

// Buy Signal
Buy = A < B;

//FirstOwnCandleStickPattern = (AA>BB) AND (CC<DD);

// Sellsignal = 0, only sell if Stop Loss or Take Profit hit
Sell = 0;

// Define Buy and Sell Price 
BuyPrice = SellPrice = Close;  
ShortPrice = CoverPrice = Close;

SLTP = (((BuyPrice/Low) - 1) * 100);

ApplyStop(stopTypeLoss, stopModePercent, SLTP , True);
ApplyStop(stopTypeProfit, stopModePercent, SLTP , True);

The variable A is defined with C > 0, because I would like to indicate every possible trade.

@EveryDayBetter , You seem to be mixing Logical (A) and Value (O1, O2, ...) values in your Entry Conditions. Not sure you are going to get what you expect.

Suggest using some Exploration Code to show your values at each step so you can see what you are actually calculating.

3 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.