NexusFi: Find Your Edge


Home Menu

 





PSAR flip notification


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,061 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

PSAR flip notification

  #1 (permalink)
 eclipsemf 
Manchester NH
 
Experience: Advanced
Platform: Thinkorswim
Broker: TD Ameritrade
Trading: Small Caps
Posts: 90 since Feb 2014
Thanks Given: 31
Thanks Received: 55

Good morning everyone, Im trying to make a quick adjustment to the PSAR indicator so I can keep a better eye on the market while im working on other things at my office. Here is the PSAR code below. I am trying to add this to it. I pulled that code from my MACD codeing I dead years ago in college and kinda forgot all of this stuff. But what im trying to do is get the audible "Ring" or "Ding" when PSAR flips. I know I have the incorrect def BUY = diff crosses but no matter what I pull from the PSAR code I cant seem to get it to ring or ding on flip it just rings every 5 mins (I trade 5 min bars) or dings every 5 when the new psar dot flips. I just want it to do that when it crosses over. Thanks for the help in advance!



THING IM TRYING TO ADD


def SELL =diff crosses below 0 ;
def BUY = diff crosses above 0 ;

alert(SELL, "SELL", Alert.BAR, Sound.Ding);
alert(BUY, "BUY", Alert.BAR, Sound.Ring);



PSAR CODE


input accelerationFactor = 0.02;
input accelerationLimit = 0.2;

assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

switch (state[1]) {
case init:
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = low;
case short:
if (SAR[1] < high)
then {
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = extreme[1];
} else {
state = state.short;
if (low < extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = low;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
}
case long:
if (SAR[1] > low)
then {
state = state.short;
acc = accelerationFactor;
extreme = low;
SAR = extreme[1];
} else {
state = state.long;
if (high > extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = high;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
}
}

plot parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Quant vue
Trading Reviews and Vendors
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
 eclipsemf 
Manchester NH
 
Experience: Advanced
Platform: Thinkorswim
Broker: TD Ameritrade
Trading: Small Caps
Posts: 90 since Feb 2014
Thanks Given: 31
Thanks Received: 55

I also tried this with the parabolic cross over and it just rings like 2 to 4 times when i add it to the chart but doesnt work with the flip yet.


input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
input crossingType = {default Bearish, Bullish};

def sar = ParabolicSAR(accelerationFactor=accelerationFactor, accelerationLimit=accelerationLimit);

plot signal = crosses(sar, close, CrossingType == CrossingType.Bearish);

signal.DefineColor("Bullish", GetColor(5));
signal.DefineColor("Bearish", GetColor(6));
signal.AssignValueColor(if crossingType == CrossingType.Bullish then signal.color("Bullish") else signal.color("Bearish"));

signal.SetPaintingStrategy(if crossingType == CrossingType.bullish
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);

alert(signal, "Bearish", Alert.BAR, Sound.Ding);
alert(signal, "Bullish", Alert.BAR, Sound.Ring);

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on September 25, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts