Code to buy/sell on a colour indicator
Forums › ProRealTime English forum › ProOrder support › Code to buy/sell on a colour indicator
- This topic has 11 replies, 3 voices, and was last updated 6 years ago by robertogozzi.
-
-
12/29/2017 at 11:23 AM #5678812/29/2017 at 11:27 AM #5678912/29/2017 at 11:57 AM #5679112/29/2017 at 11:59 AM #56792
Here is the code:
//PRC_SwingLine Ron Black | indicator
//20.09.2017
//Nicolas @ http://www.prorealcode.com
//Sharing ProRealTime knowledgeif upsw=1 then
if high>hH then
hH=high
endif
if low>hL then
hL=low
endifif high<hL then
upsw=0
lL=low
lH=high
endif
endifif upsw=0 then
if low<lL then
lL=low
endif
if high<lH then
lH=high
endifif low>lH then
upsw=1
hH=high
hL=low
endif
endifif upsw=1 then
swingline=hL
r=0
g=255
b=255
else
swingline=lH
r=255
g=0
b=255
endifreturn swingline coloured(r,g,b) style(line,2) as “Swing Line”
12/29/2017 at 12:25 PM #56793use the <> symbol to post code and a screenshot of indi on a chart would be nice , Some clear definition of EXACTLY what you require would be nice as well
If you require a sell/buy on indicator colourchange you will need more than just an indicator also >> a pro order code required
Hint its pretty hard to produce an accurate precision pro order code on ambiguous non existant plan … details required
12/29/2017 at 12:42 PM #56794123456789101112131415161718192021222324252627282930313233343536373839404142434445464748//PRC_SwingLine Ron Black | indicator//20.09.2017//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledgeif upsw=1 thenif high>hH thenhH=highendifif low>hL thenhL=lowendifif high<hL thenupsw=0lL=lowlH=highendifendifif upsw=0 thenif low<lL thenlL=lowendifif high<lH thenlH=highendifif low>lH thenupsw=1hH=highhL=lowendifendifif upsw=1 thenswingline=hLr=0g=255b=255elseswingline=lHr=255g=0b=255endifreturn swingline coloured(r,g,b) style(line,2) as "Swing Line"12/29/2017 at 12:44 PM #5679612/29/2017 at 1:10 PM #56799The magenta and green lines weaving through the candles are the indicator
Still not a precise request but ive assumed this is what you require , you need to get better at defining parameters , still very ambiguous . Anyway as i expected what ive written chops you up in all but strong trending periods . More filter required imo
1234567891011121314151617181920212223242526272829303132333435363738// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = CALL "PRC_SwingLine Ron Black"indicator2 = CALL "PRC_SwingLine Ron Black"c1 = (indicator1[1] < indicator2)IF c1 THENBUY 1 SHARES AT MARKETENDIF// Conditions to exit long positionsindicator3 = CALL "PRC_SwingLine Ron Black"indicator4 = CALL "PRC_SwingLine Ron Black"c2 = (indicator3[1] > indicator4)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator5 = CALL "PRC_SwingLine Ron Black"indicator6 = CALL "PRC_SwingLine Ron Black"c3 = (indicator5[1] > indicator6)IF c3 THENSELLSHORT 1 SHARES AT MARKETENDIF// Conditions to exit short positionsindicator7 = CALL "PRC_SwingLine Ron Black"indicator8 = CALL "PRC_SwingLine Ron Black"c4 = (indicator7[1] < indicator8)IF c4 THENEXITSHORT AT MARKETENDIF12/29/2017 at 1:30 PM #5680112/29/2017 at 1:34 PM #56802This is probably a better easier way to produce code
12345678910111213141516171819202122232425262728293031323334353637383940414243// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// indicator shortcutz = CALL "PRC_SwingLine Ron Black"// Conditions to enter long positionsindicator1 = zindicator2 = zc1 = (indicator1[1] < indicator2)IF c1 THENBUY 1 SHARES AT MARKETENDIF// Conditions to exit long positionsindicator3 = zindicator4 = zc2 = (indicator3[1] > indicator4)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator5 = zindicator6 = zc3 = (indicator5[1] > indicator6)IF c3 THENSELLSHORT 1 SHARES AT MARKETENDIF// Conditions to exit short positionsindicator7 = zindicator8 = zc4 = (indicator7[1] < indicator8)IF c4 THENEXITSHORT AT MARKETENDIF12/29/2017 at 1:39 PM #56805Or even go a step further . Just trying to reduce lines and characters in code , this is all good practice for me
123456789101112131415161718192021222324252627282930313233343536373839// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// indicator shortcutz = CALL "PRC_SwingLine Ron Black"// Conditions to enter long positionsc1 = z[1] < zIF c1 THENBUY 1 SHARES AT MARKETENDIF// Conditions to exit long positionsc2 = z[1] > zIF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsc3 = z[1] > zIF c3 THENSELLSHORT 1 SHARES AT MARKETENDIF// Conditions to exit short positionsc4 = z[1] < zIF c4 THENEXITSHORT AT MARKETENDIF1 user thanked author for this post.
12/29/2017 at 11:16 PM #56848Colours don’t exist, they are just a graphical way to make prices/lines clearer.
If a candlestick is blue (or green or white) you know it’s a BULLish one. A piece of code can only tell it because you let it compare the closing price to the opening one, if it’s greater it must be BULLish!
So to know if a n SMA line is green you simply have to test whether the current closing price is greater than the one of the previous candlestick
12345678Sma = average[20](close)IF Sma > Sma[1] THEN //Green/Blue/White colour (Bullish)..ELSE //Red/Black colour (Bearish)..ENDIF1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on