Gamestudio Links
Zorro Links
Newest Posts
Alternative to Stooq for Zorro S
by cwford. 10/09/26 21:13
Stooq now requires an API key
by cwford. 10/08/26 23:27
ZorroGPT
by TipmyPip. 10/06/26 05:32
Purchase A8 full licence version
by jcl. 10/05/26 12:12
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 19,389 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
MMI and Thinkscript - Think or Swim #475451
12/10/18 22:56
12/10/18 22:56
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
I'm trying to convert the lite C version of MMI into thinkscript so that I can use MMI with think or swim.

I've coded up the following but I'm not 100% sure it's doing what it's supposed to do as the iterator logic is different in thinkscript than anything I've seen. Thinkscript uses fold instead of for loops. See https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold.html

The trickiest part was calculating nh and nl as these are iterated for each price in the lookback series.

The input mmiLength section lets the user define how far back you want to look. I choose 150 as a default value based off of a previous post from JCL that said 100-200 bars is a good compromise.

Here's my solution. Anyone see any problems with it?

input mmiLength = 150;
def m = Median(close, mmiLength);

def nh = fold i = 1 to mmiLength+1 with p = 0 do if close[i] > m and close[i] > getValue(close, i + 1) then p+1 else p+0;

def nl = fold j = 1 to mmiLength+1 with q = 0 do if close[j] < m and close[j] < getValue(close, j + 1) then q+1 else q+0;

plot mmi= 100*(nl+nh)/(mmiLength-1);

Re: MMI and Thinkscript - Think or Swim [Re: chsmac85] #475452
12/11/18 00:45
12/11/18 00:45
Joined: Aug 2018
Posts: 103
O
OptimusPrime Offline
Member
OptimusPrime  Offline
Member
O

Joined: Aug 2018
Posts: 103
Hi chsmac85:

This is a Zorro specific forum.. We are trying to learn and improve our use of Lite-C specifically. Did you try a similiar forum specifically for ThinkorSwim coding?


Thanks so much,

OptimusPrime

Re: MMI and Thinkscript - Think or Swim [Re: OptimusPrime] #475453
12/11/18 02:36
12/11/18 02:36
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
sorry I didn't. I considered MMI to be a part of the zorro family and posted in the brokers section given think or swim is a platform for a very popular broker. But that's fine, I can look for help elsewhere.


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1