Hello:
I was hoping someone could help me with a coding issue I am having:
When a trigger occurs, I am trying to draw a continuous horizontal line from that close until the next trigger occurs - then it will again draw a horizontal line from that close until the next trigger.
I thought it would be like:
trigger := if (cross(close,ma(close,30),1,0);.....................................(produce the trigger and get a 1 or 0 result)
b := barssince(trigger);.................................................................... (find out the amount of bars since the trigger happened)
horizontal_line : ref(close,b);........................................................ (have it draw a continuous horizontal line at the close where the trigger happened until the next trigger
This is easily done in the Think or Swim platform - but I am having trouble trying to code it in this Formula Script
Thanks,
Brian
Could use some help with a coding issue
Moderator: Chris White
-
- Posts: 212
- Joined: Mon Nov 29, 2010 9:21 pm
Re: Could use some help with a coding issue
Hi Brian,
You can use VALUEWHEN(CLOSE, Trigger) to get the value of Close when the trigger is true.
Here's the full script:
This produces the following plot:
You can use VALUEWHEN(CLOSE, Trigger) to get the value of Close when the trigger is true.
Here's the full script:
Code: Select all
trigger:= IF(CROSS(CLOSE, MA(CLOSE,30)),1,0);
B: VALUEWHEN(CLOSE,trigger),colorblue,width2,pointdot;
Re: Could use some help with a coding issue
What a Simple - Brilliant & Elegant Solution
Many Thanks!
-Brian
Many Thanks!
-Brian