Help adding a Pivot Range to following code: - MultiCharts | futures io social day trading
futures io futures trading


Help adding a Pivot Range to following code:
Updated: Views / Replies:858 / 3
Created: by olobay Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Help adding a Pivot Range to following code:

  #1 (permalink)
Elite Member
Montreal
 
Futures Experience: Intermediate
Platform: MultiCharts
Broker/Data: IB Canada/IQFeed
Favorite Futures: TF, CL
 
Posts: 261 since Jul 2011
Thanks: 288 given, 332 received

Help adding a Pivot Range to following code:

Hi,

I am hoping that somebody will be able to help me. I would like to add a range around the Pivot in the code below. The math for that range is (yesterday's high + yesterday's low) /2. Then you subtract that from the pivot value (high+low+close)/3 and it gives you a value. Then you add that value to the pivot and you have an upper range. Then you subtract that value from the pivot to get the lower range. So the new study will plot exactly the same as the code below but will also plot 2 additional horizontal lines forming a pivot range.

Thanks.

 
Code
[LegacyColorValue = true]; 

{based on intraday data (is sometimes a little different than daily data, so won't match exact)}
{idea is that it will change each day @ "NewDayTM", to reflect the next days numbers.}
{..check the open/close values to verify the day it's showing. It seems to work}
{always posting 1 bar behind, since must be NO on "update value intra-bar"}

{The indicator has an input called PivotType. Use 3 or 4 as PivotType and you should get the Settlement Price, 
since when PivotType = 3 or 4, the CloseD function is used. The CloseD will return the settlement price. }

input: PivotType(0),
   BarsBack(60),
   ShowClose(1),
   ShowOpen(1),
   ShowHalfPivots(1),
   ShowLevel(0),
   DaysBack(1),
   NewDayTM(1510),
   RoundLevels(false),
   DecPlaces(2),
   SupResType(0);
   
var: theday(0);
var: Maxcnt(11);
array:
   TL[12](-1),Val[12](-1),
   Color[12](6),Label[12]("L"),FTextID[12](-1), TLabel[12](" ");

var: cnt(0),sdate(0),stime(0),fPivot(0),twOpen(0),theRange(0);

if lastbaronchart then begin

if time >= NewDayTM then theday = 0  else theday = 1;
theday = theday + DaysBack-1;
if theday <= 0 then begin 
   theday = 0;
   twOpen = 0;
end else twopen = theday-1;  {make sure this weeks open isn't <0}

{store weekly Open and Close that we care about}
Val[10] = CloseD(theday);
if PivotType >0 and PivotType <4 then Val[11] = OpenD(twopen) else Val[11] = OpenD(theday);

{calculate central pivot based on pivot type}{not sure how usefull some of these might be}
if      PivotType = 1 then fPivot = (HighD(theday) + LowD(theday) + Val[11]) /3
else if PivotType = 2 then fPivot = (HighD(theday) + LowD(theday) + Val[11] + Val[11]) /4
else if PivotType = 3 then fPivot = (HighD(theday) + LowD(theday) + Val[10] + Val[11]) /4
else if PivotType = 4 then fPivot = (HighD(theday) + LowD(theday) + Val[10] + Val[11]) /4
else fPivot = (HighD(theday) + LowD(theday) + Val[10]) /3; {default standard Pivot}

if SupResType = 1 then begin {seems like there is always a little different way to do these}
   theRange = (HighD(theday) - LowD(theday))/2;
   VAl[1] = fPivot;
   VAl[2] = fPivot + theRange; {R1}
   VAl[3] = fPivot - theRange; {S1}
   
   VAl[4] = VAl[2] + theRange; {R2}
   VAl[5] = VAl[3] - theRange; {S2}
   
   VAl[6] = VAl[4] + theRange; {R3}
   VAl[7] = VAl[5] - theRange; {S3}
   VAl[8] = VAl[6] + theRange; {R4}
   VAl[9] = VAl[7] - theRange; {S4}
end
else begin
   VAl[1] = fPivot;
   VAl[2] = fPivot + fPivot - LowD(theday); {R1}
   VAl[3] = fPivot + fPivot - HighD(theday); {S1}
   
   VAl[4] = fPivot + VAl[2] - VAl[3]; {R2}
   VAl[5] = fPivot - VAl[2] + VAl[3]; {S2}
   
   VAl[6] = fPivot + VAl[4] - VAl[3]; {R3}
   VAl[7] = fPivot - VAl[4] + VAl[3]; {S3}
   VAl[8] = fPivot + VAl[4] - VAl[5]; {R4}
   VAl[9] = fPivot - VAl[4] + VAl[5]; {S4}
end;

if RoundLevels then begin
   for cnt = 1 to 11 begin
      val[cnt] = roundInst(val[cnt]);
   end;
end;

Color[1] = Yellow;
Color[2] = Darkred;
Color[3] = Darkgreen;
Color[4] = Darkred;
Color[5] = Darkgreen;
Color[6] = Darkred;
Color[7] = Darkgreen;
Color[8] = Darkred;
Color[9] = Darkgreen;
Color[10] = Yellow;
Color[11] = DarkBrown;

TLabel[1] = "Pivot - ";
TLabel[2] = "R1 - ";
TLabel[3] = "S1 - ";
TLabel[4] = "R2 - ";
TLabel[5] = "S2 - ";
TLabel[6] = "R3 - ";
TLabel[7] = "S3 - ";
TLabel[8] = "R4 - ";
TLabel[9] = "S4 - ";
TLabel[10] = "Close - ";
TLabel[11] = "Open - ";
   

sdate = Date[BarsBack];
stime = Time[BarsBack];


for cnt= 1 to Maxcnt begin
   if cnt < 10 or (ShowClose <> 0 and cnt = 10) or (ShowOpen <> 0 and cnt = 11) then begin
      if TL[cnt] < 0 then begin {dosn't exist, create new TL}
         TL[cnt] = TL_New (sdate, stime, Val[cnt],
            date, time , Val[cnt]);
         TL_SetColor (TL[cnt], Color[cnt]);
         if cnt >= 10 then TL_SetStyle (TL[cnt], Tool_Dashed)
            else TL_SetStyle (TL[cnt], Tool_Dashed);
      end;
      if TL_Exist(TL[cnt]) then begin {exist}
         TL_SetEnd (TL[cnt], date, time , Val[cnt]);
         TL_SetBegin (TL[cnt], sdate, stime, Val[cnt]); {reset TL}
      end;
   
      {do text stuff}
      if FTextID[cnt] < 0 then begin  {is new}
         FTextID[cnt] = Text_New(sdate, stime, Val[cnt], "zzz");
         Text_SetStyle(FTextID[cnt], 1, 2);
         Text_SetColor(FTextID[cnt], Color[cnt]);
      end;
      if FTextID[cnt] >= 0 then begin  {already exists}
         Text_SetLocation(FTextID[cnt], sdate, stime, Val[cnt]);
         Text_SetString(FTextID[cnt],TLabel[cnt] + NumToStr(Val[cnt], DecPlaces) + " " );
      end;
   end; {count < 6, etc.}
end; {cnt}

Array: HalfTL[9](-1),HalfVal[9](0),HTextID[9](-1);

if ShowHalfPivots <> 0 then begin
   HalfVal[1] = ((Val[4] - Val[2])/2) + Val[2];
   HalfVal[2] = ((Val[2] - Val[1])/2) + Val[1];
   HalfVal[3] = ((Val[1] - Val[3])/2) + Val[3];
   HalfVal[4] = ((Val[3] - Val[5])/2) + Val[5]; {s1-s2}
   HalfVal[5] = ((Val[4] - Val[6])/2) + Val[6];
   HalfVal[6] = ((Val[5] - Val[7])/2) + Val[7]; {s2-s3}
   HalfVal[7] = ((Val[6] - Val[8])/2) + Val[8];
   HalfVal[8] = ((Val[7] - Val[9])/2) + Val[9]; {s3-s4}

   if RoundLevels then begin
      for cnt = 1 to 8 begin
         HalfVal[cnt] = roundInst(HalfVal[cnt]);
      end;
   end;

   for cnt= 1 to 8 begin
      if HalfTL[cnt] < 0 then begin {dosn't exist, create new TL}
         HalfTL[cnt] = TL_New (sdate, stime, HalfVal[cnt],
            date, time , HalfVal[cnt]);
         TL_SetColor (HalfTL[cnt], DarkGray);
         TL_SetStyle (HalfTL[cnt], Tool_Dashed);
      end;
      if TL_Exist(HalfTL[cnt]) then begin {exist}
         TL_SetEnd (HalfTL[cnt], date, time , HalfVal[cnt]);
         TL_SetBegin (HalfTL[cnt], sdate, stime, HalfVal[cnt]); {reset TL}
      end;
      
      {do text stuff}
      if HTextID[cnt] < 0 then begin  {is new}
         HTextID[cnt] = Text_New(sdate, stime, HalfVal[cnt], "zzz");
         Text_SetStyle(HTextID[cnt], 1, 2);
         Text_SetColor(HTextID[cnt], DarkGray);
      end;
      if HTextID[cnt] >= 0 then begin  {already exists}
         Text_SetLocation(HTextID[cnt], sdate, stime, HalfVal[cnt]);
         Text_SetString(HTextID[cnt], NumToStr(HalfVal[cnt], DecPlaces) + " " );
      end;
   end; {cnt}
end; {ShowHalfPivots}

end; {last bar}

if ShowLevel > 0 and ShowLevel <= 4 then begin
   noplot(2);
   noplot(3);
   if ShowLevel = 1 then begin
      Plot2[-1](Val[2] + .5,"h");
      Plot3[-1](Val[3] - .5,"l");
   end
   else if ShowLevel = 2 then begin
      Plot2[-1](Val[4] + .5,"h");
      Plot3[-1](Val[5] - .5,"l");
   end
   else if ShowLevel = 3 then begin
      Plot2[-1](Val[6] + .5,"h");
      Plot3[-1](Val[7] - .5,"l");
   end
   else if ShowLevel = 4 then begin
      Plot2[-1](Val[8] + .5,"h");
      Plot3[-1](Val[9] - .5,"l");
   end;

end;

Reply With Quote
 
  #2 (permalink)
Trading for Fun
London
 
Futures Experience: None
Platform: mc, TS, ninja
Favorite Futures: es
 
Bimi's Avatar
 
Posts: 118 since Mar 2010
Thanks: 42 given, 58 received

do you want someone to code it for you?

Reply With Quote
 
  #3 (permalink)
Elite Member
Montreal
 
Futures Experience: Intermediate
Platform: MultiCharts
Broker/Data: IB Canada/IQFeed
Favorite Futures: TF, CL
 
Posts: 261 since Jul 2011
Thanks: 288 given, 332 received


I think I'd be able to figure it out but I'm not sure exactly where to add in the code that I want.

Reply With Quote
 
  #4 (permalink)
Trading for Fun
London
 
Futures Experience: None
Platform: mc, TS, ninja
Favorite Futures: es
 
Bimi's Avatar
 
Posts: 118 since Mar 2010
Thanks: 42 given, 58 received


olobay View Post
I think I'd be able to figure it out but I'm not sure exactly where to add in the code that I want.

you can add it att the end

Reply With Quote

Reply



futures io > > > > Help adding a Pivot Range to following code:

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Req Pivot Range Historical for Ninja6.5 jeya NinjaTrader Programming 7 July 2nd, 2012 06:49 AM
Logical Trader indicator for Pivot Range, any help? hector24 NinjaTrader 3 June 24th, 2012 07:30 AM
Help on Adding Order management code jkpdon NinjaTrader Programming 3 December 31st, 2011 04:01 PM


All times are GMT -4. The time now is 05:56 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.09 seconds with 19 queries on phoenix via your IP 54.82.79.109