Pattern scanner

Questions about MultiCharts and user contributed studies.
Giosuè
Posts: 6
Joined: 02 Dec 2020

Pattern scanner

Postby Giosuè » 02 Dec 2020

Hello, I have to program a code in powerlanguage for Multicharts where in the strategy optimization phase it makes me a scanner with the various price patterns. The problem I can't write the code correctly .. can anyone help me?

//Function :Pattern Base "PtnBaseSA"

Var:
opend0(0), opend1(1),
highd0(0), highd1(0);

Array:
definizioneptn[4](0);

opend0=opens(0);
opend1=opens(1);

highd0=highs(0);
highd1=highs(1);

definizioneptn[1] = ((highd0-opend0)>((highd1-opend1)*1));
definizioneptn[2] = ((highd0-opend0)>((highd1-opend1)*1.5));
definizioneptn[3] = true;
definizioneptn[4] = false;

PtnBaseSA = definizioneptn[numeropattern];


My strategy


Input: MyPtnLY(4), MyPtnSY(4), MyPtnLN(4), MyPtnSN(4);
Input: MyStardTrade(00), MyEndTrade(00), MyStartPause(1200), MyEndPause(1100); //inputs orari della finestra temporale
Input: MyStop(100), MyProfit(0);

If Time > MyStardTrade and Time < MyEndTrade and (Time < MyStartPause or Time > MyEndPause) then begin //fasce orarie in cui operare
If PtnBaseSA(MyPtnLY) = True and PtnBaseSA(MyPtnLN) = False then buy next bar at Highd(o) stop; //compra se siamo long al massimo di giornata
If PtnBaseSA(MyPtnSY) = True and PtnBaseSA(MyPtnSN) = False then sellshort next bar at Lowd(o) stop; //compra se siamo short al minimo di giornata
end;

Setstopcontract;
If MyStop > 0 then setstoploss(MyStop);
If MyProfit > 0 then setprofittarget(MyProfit);


You can help me??

Best regards

Giosuè

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Pattern scanner

Postby TJ » 02 Dec 2020

See post #1 & post #2
viewtopic.php?t=11713

Giosuè
Posts: 6
Joined: 02 Dec 2020

Re: Pattern scanner

Postby Giosuè » 02 Dec 2020

Thank you very much TJ, so i write the code correctly..

Code: Select all

//Function :Pattern Base "PtnBaseSA" Var: opend0(0), opend1(1), highd0(0), highd1(0); Array: definizioneptn[4](0); opend0=opens(0); opend1=opens(1); highd0=highs(0); highd1=highs(1); definizioneptn[1] = ((highd0-opend0)>((highd1-opend1)*1)); definizioneptn[2] = ((highd0-opend0)>((highd1-opend1)*1.5)); definizioneptn[3] = true; definizioneptn[4] = false; PtnBaseSA = definizioneptn[numeropattern];

Code: Select all

//My strategy Input: MyPtnLY(4), MyPtnSY(4), MyPtnLN(4), MyPtnSN(4); Input: MyStardTrade(00), MyEndTrade(00), MyStartPause(1200), MyEndPause(1100); //inputs orari della finestra temporale Input: MyStop(100), MyProfit(0); If Time > MyStardTrade and Time < MyEndTrade and (Time < MyStartPause or Time > MyEndPause) then begin //fasce orarie in cui operare If PtnBaseSA(MyPtnLY) = True and PtnBaseSA(MyPtnLN) = False then buy next bar at Highd(o) stop; //compra se siamo long al massimo di giornata If PtnBaseSA(MyPtnSY) = True and PtnBaseSA(MyPtnSN) = False then sellshort next bar at Lowd(o) stop; //compra se siamo short al minimo di giornata end; Setstopcontract; If MyStop > 0 then setstoploss(MyStop); If MyProfit > 0 then setprofittarget(MyProfit);

Giosuè
Posts: 6
Joined: 02 Dec 2020

Re: Pattern scanner

Postby Giosuè » 03 Dec 2020

Thank you very much TJ, so i write the code correctly..

I specify that the function code gives me an error while the strategy code is correct.
I hope for your help!!
Thank you very much

Code: Select all

//Function :Pattern Base "PtnBaseSA" Var: opend0(0), opend1(1), highd0(0), highd1(0); Array: definizioneptn[4](0); opend0=opens(0); opend1=opens(1); highd0=highs(0); highd1=highs(1); definizioneptn[1] = ((highd0-opend0)>((highd1-opend1)*1)); definizioneptn[2] = ((highd0-opend0)>((highd1-opend1)*1.5)); definizioneptn[3] = true; definizioneptn[4] = false; PtnBaseSA = definizioneptn[numeropattern];

Code: Select all

//My strategy Input: MyPtnLY(4), MyPtnSY(4), MyPtnLN(4), MyPtnSN(4); Input: MyStardTrade(00), MyEndTrade(00), MyStartPause(1200), MyEndPause(1100); //inputs orari della finestra temporale Input: MyStop(100), MyProfit(0); If Time > MyStardTrade and Time < MyEndTrade and (Time < MyStartPause or Time > MyEndPause) then begin //fasce orarie in cui operare If PtnBaseSA(MyPtnLY) = True and PtnBaseSA(MyPtnLN) = False then buy next bar at Highd(o) stop; //compra se siamo long al massimo di giornata If PtnBaseSA(MyPtnSY) = True and PtnBaseSA(MyPtnSN) = False then sellshort next bar at Lowd(o) stop; //compra se siamo short al minimo di giornata end; Setstopcontract; If MyStop > 0 then setstoploss(MyStop); If MyProfit > 0 then setprofittarget(MyProfit);
Thank you very much TJ, so i write the code correctly..

Code: Select all

//Function :Pattern Base "PtnBaseSA" Var: opend0(0), opend1(1), highd0(0), highd1(0); Array: definizioneptn[4](0); opend0=opens(0); opend1=opens(1); highd0=highs(0); highd1=highs(1); definizioneptn[1] = ((highd0-opend0)>((highd1-opend1)*1)); definizioneptn[2] = ((highd0-opend0)>((highd1-opend1)*1.5)); definizioneptn[3] = true; definizioneptn[4] = false; PtnBaseSA = definizioneptn[numeropattern];

Code: Select all

//My strategy Input: MyPtnLY(4), MyPtnSY(4), MyPtnLN(4), MyPtnSN(4); Input: MyStardTrade(00), MyEndTrade(00), MyStartPause(1200), MyEndPause(1100); //inputs orari della finestra temporale Input: MyStop(100), MyProfit(0); If Time > MyStardTrade and Time < MyEndTrade and (Time < MyStartPause or Time > MyEndPause) then begin //fasce orarie in cui operare If PtnBaseSA(MyPtnLY) = True and PtnBaseSA(MyPtnLN) = False then buy next bar at Highd(o) stop; //compra se siamo long al massimo di giornata If PtnBaseSA(MyPtnSY) = True and PtnBaseSA(MyPtnSN) = False then sellshort next bar at Lowd(o) stop; //compra se siamo short al minimo di giornata end; Setstopcontract; If MyStop > 0 then setstoploss(MyStop); If MyProfit > 0 then setprofittarget(MyProfit);

Giosuè
Posts: 6
Joined: 02 Dec 2020

Re: Pattern scanner

Postby Giosuè » 03 Dec 2020

hello, is there anybody who can help me?

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Pattern scanner

Postby rrams » 03 Dec 2020

You forgot to add the input statement to the PtnBaseSA function:

Code: Select all

inputs: numeropattern(numericsimple);

Giosuè
Posts: 6
Joined: 02 Dec 2020

Re: Pattern scanner

Postby Giosuè » 04 Dec 2020

You forgot to add the input statement to the PtnBaseSA function:

Code: Select all

inputs: numeropattern(numericsimple);
Thank you very much..
but it keeps giving me error:

------ Compiled with error(s): ------
Bracket '[' expected
line 18, column 6
'(' Expected
line 18, column 6

"opend0=opens(0);"

Giosuè
Posts: 6
Joined: 02 Dec 2020

Re: Pattern scanner

Postby Giosuè » 04 Dec 2020

You forgot to add the input statement to the PtnBaseSA function:

Code: Select all

inputs: numeropattern(numericsimple);
Thank you very much..
but it keeps giving me error:

------ Compiled with error(s): ------
Bracket '[' expected
line 18, column 6
'(' Expected
line 18, column 6

"opend0=opens(0);"

I think that the bracket are ok!!

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Pattern scanner

Postby rrams » 04 Dec 2020

Yes, a function call uses a parenthesis and OpenS(0) is a valid function. The syntax of that part of your code is correct. Except HighD(o) is using the letter 'o' instead of the number zero '0'. You need to change that.

Square brackets '[ ]' are used to reference array and series elements. You did that okay except definizioneptn[ ] needs to use an index from zero through three for an array with length of four. Also it needs to be initialized with a boolean type. Some compilors let you use integers zero for false and one for true interchangeably but not EasyLanguage.

I don't know exactly what you are trying to do with the signal other than optimize on some patterns. Looks like you are close. Good luck!


Return to “MultiCharts”